window.onload = function(){
	//1.获取节点
	var picBox = document.getElementById("picBox");
	var imgs = picBox.getElementsByTagName("img");
    var scrUl = document.getElementById("scrUl");
    var lis = scrUl.getElementsByTagName("li");
   // console.log(imgs);//检测节点是否被获取
    //2.封装函数
    //申明一个变量来索引图片
    var index = 0;
    function scroll(){
    	index++;
       if(index == 6){
      	index = 0;
        }
      //1.隐藏所有的图片
       for(var i=0;i<imgs.length;i++){
		 imgs[i].style.display = "none";
//		 lis[i].style.background = "#fff";
// 	     lis[i].style.color = "#000";  
	   }
         imgs[index].style.display = "block";
//       lis[index].style.background = "orange";
// 	     lis[index].style.color = "#fff";
    }
    //3.加定时器
    var t = setInterval(scroll,1000);
    //4.鼠标移入的事件
    picBox.onmouseover = function(){
    	clearInterval(t);
    }
    //5.鼠标移出的事件
    picBox.onmouseout = function(){
    	t = setInterval(scroll,1000); 
    }
    //6.小圆点
     for(var j=0;j<lis.length;j++){
     	//给小圆点对象自定义属性suoYin，将j的值赋值给它
     	lis[j].suoYin = j;
     	lis[j].onmouseover = function(){
     		index = this.suoYin;
     	//1.隐藏所有的图片
       for(var i=0;i<imgs.length;i++){
		 imgs[i].style.display = "none";
		 lis[i].style.background = "#fff";
   	     lis[i].style.color = "#000";  
	   }
         imgs[index].style.display = "block";
         lis[index].style.background = "orange";
   	     lis[index].style.color = "#fff";	
     	}
     }
}//加载函数

